package com.csoft.riskroll;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;

/**
 * RiskRoll v 1.0
 * @author John Cline
 * 13 July 2010
 *
 * Note: Version number is relatively arbitrary. This isn't my 1.0 release, but it's
 * better than a 0.1.
 * 
 * This class is used upon startup. Simply grabs preferences and starts the proper intent
 * as selected in the preferences.
 * 
 * Dice icon obtained from http://www.psdgraphics.com/
 * This code is distributed under Apache v2, available http://www.apache.org/licenses/LICENSE-2.0
 * Please note that "Shaker" is licensed under Apache v2.
 */

public class RiskStart extends Activity {
    private SharedPreferences settings;
    private String defaultScreen;
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
    
    @Override
    public void onStart() {
    	super.onStart();
    	/*
    	 * Loads preferences on startup.
    	 */
    	getPrefs();
    	if (defaultScreen.contains("auto")) {
    		startActivity(new Intent(this, RiskAutoRoll.class));
			this.finish();
     	} else {
    		startActivity(new Intent(this, RiskRoll.class));
			this.finish();
    	}
    }
    
    private void getPrefs() {
    	/*
    	 * Loads the preferences into locally stored variables.
    	 */
    	settings = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
    	defaultScreen = settings.getString("default_screen", "classic");
    }
}
